package logic

import (
	"context"
	"go.uber.org/zap"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"

	"github.com/zeromicro/go-zero/core/logx"
)

type CartDelGoodsLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewCartDelGoodsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *CartDelGoodsLogic {
	return &CartDelGoodsLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *CartDelGoodsLogic) CartDelGoods(in *homepage.CartDelGoodsRequest) (*homepage.CartDelGoodsResponse, error) {
	// todo: add your logic here and delete this line
	err := dao.CartDelGoods(int(in.UserId), int(in.GoodsId))
	if err != nil {
		pkg.Error("删除商品失败", zap.Error(err))
		return nil, err
	}
	return &homepage.CartDelGoodsResponse{Msg: "删除商品成功"}, nil
}
